<template>
  <div>
     <DetailPage :key="key" v-bind="detailConfig" :model="nowData"></DetailPage>
  </div>
</template>

<script setup lang="ts">
import { onMounted, reactive } from 'vue'
import apiMod from '@/apiMod/index'
import { getAreaObj } from '@/utils/util'
import DetailPage from '@/views/aplid/DetailPage/index.vue'
import { detailConfig } from '../config'
import { revertUTF8 } from '@/views/oneStopOffice/utils/index'

type Props = {
  nowRowData?: any;
}
const props = withDefaults(defineProps<Props>(), {
  nowRowData: {}
});
let nowData: any = reactive({
  infoImg: '',
  infoTitle: ''
})
let key = ref(1)
const getInitData = ()=> {
    apiMod.view_dpPolicyDocument_view(props.nowRowData.id).then((res) => {
      let areasInfo: any = getAreaObj(res.data, 'from', 'set')
      res.data.areas= areasInfo.areaIds
			res.data.areasName= areasInfo.names
      if(res.image){
        res.image = res.image.split(',')[0]
      }
      if(res.data.policyContent){
				res.data.policyContent = revertUTF8(res.data.policyContent) 
			}
      // 输入框都进行一下解密
      detailConfig.column.forEach(el=>{
        if((!el.type||el.type=='input'||el.type=="text")&& res.data[el.prop]){
          res.data[el.prop] =  revertUTF8(res.data[el.prop])
        }
      })
      nowData = res.data
    key.value = Math.random()
  })
}

onMounted(() => {
  getInitData()
})
</script>
